﻿
Imports elpmis
Imports webctrl

Namespace lpmsservFunctions

    'parameters, page, optional, the xhtmlpage instance
    '            inlineScript, optional, the inlineScript of an xhtmlpage, overwrite page
    '            action, any, convert to string by changeInnerHtmlById
    '            interval, int/var, ms of interval
    'return, string, action target
    Public Class jsInterval
        Inherits internalFunction

        Public Class parameters
            Public Const page As String = "page"
            Public Const inlineScript As String = "inlineScript"
            Public Const action As String = "action"
            Public Const interval As String = "interval"
        End Class

        Public Sub New()
            MyBase.New("js.interval")
        End Sub

        Protected Overrides Function invoke(ByVal ctx As context, ByRef output As bare_variable) As Boolean
            Dim action As String = Nothing
            If ctx.findVariableStr(parameters.action, action) Then
                Dim intv As Int64 = Nothing
                If ctx.findVariableInt(parameters.interval, intv) Then
                    Dim inlineScript As inlineScript = Nothing
                    getinlinescript(ctx, inlineScript, parameters.page, parameters.inlineScript)
                    output = New bare_variable(typeDefination.string, interval.invoke(inlineScript, action, intv))
                    Return True
                Else
                    raiseError("expect parameter " + parameters.interval, errorHandle.errorType.user)
                    Return False
                End If
            Else
                raiseError("expect parameter " + parameters.action, errorHandle.errorType.user)
                Return False
            End If
        End Function
    End Class

End Namespace
